home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Buffers / Buffer.cp next >
Encoding:
Text File  |  1997-06-28  |  610 b   |  36 lines  |  [TEXT/CWIE]

  1. // Buffer.cp
  2.  
  3. #ifndef Bufferr_h
  4. #include "Buffer.h"
  5. #endif
  6. #ifndef ConstBuffer_h
  7. #include "ConstBuffer.h"
  8. #endif
  9.  
  10. Buffer::Buffer( Data theSpace )
  11.   : space( theSpace ),
  12.      mark( 0 )
  13.   {
  14.     Assert( !theSpace.Null() );
  15.   }
  16.  
  17. void Buffer::Reset( Data theSpace )
  18.   {
  19.     Assert( !theSpace.Null() );
  20.     space = theSpace;
  21.     mark = 0;
  22.   }
  23.  
  24. void Buffer::operator<<( ConstData toWrite )
  25.   {
  26.     Assert( toWrite.Length() <= UnusedLength() );
  27.     mark += Unused() << toWrite;
  28.   }
  29.  
  30. void Buffer::operator<<( ConstBuffer& source )
  31.   {
  32.     uint32 amount = Unused() << source.Unused();
  33.     AdvanceMark( amount );
  34.     source.AdvanceMark( amount );
  35.   }
  36.